﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace KhachSan.Process.Private.Bo
{
    public partial class UC_Phong : UserControl
    {
        private Class.Phong _phong;
        public PanelControl _State
        {
            get { return this.State; }
            set { this.State = value; }
        }
        public LabelControl _TieuDe
        {
            get { return this.lbTenPhong; }
            set { lbTenPhong = value; }
        }
        public PanelControl _TrangThaiPhong
        {
            get { return this._trangThaiPhong; }
            set{ _trangThaiPhong=value;}
        }      
        public Class.Phong _Phong
        {
            get { return _phong; }
            set { _phong = value; }
        }       
        public UC_Phong()
        {
            InitializeComponent();
        }

        private void Phong_Load(object sender, EventArgs e)
        {
            
        }
        private void times_Tick(object sender, EventArgs e)
        {
            
        }
        public void Mo()
        {
            _trangThaiPhong.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.Flat;
            _trangThaiPhong.Appearance.BorderColor = Color.Lime;
        }
        public void Sang()
        {
            _trangThaiPhong.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
     
            _trangThaiPhong.Appearance.BorderColor = Color.Lime;
        }
        private void _trangThaiPhong_Resize(object sender, EventArgs e)
        {
            int x,y;
            //x=(_trangThaiPhong.Width/2) - (light.Width/2);
            //y=(_trangThaiPhong.Height/2)-(light.Height/2);
            //light.SetBounds(x,y,light.Width,light.Height);
        } 
        private void _trangThaiPhong_MouseHover(object sender, EventArgs e)
        {
            if(!down)
                hover(this._phong);
        }
        private void _trangThaiPhong_MouseLeave(object sender, EventArgs e)
        {
            if(!down)
                di(this);
        }
        
        public delegate void Hover(Class.Phong phong);
        public Hover hover;
        public delegate void leave(UC_Phong phong);
        public leave di;
        public delegate void DuyChuyen(UC_Phong phong);
        public delegate void PhongUp(UC_Phong phong);
        public DuyChuyen Phong_Move;
        public PhongUp Phong_Up;
        private void light_Click(object sender, EventArgs e)
        {

        }

        private void State_MouseDown(object sender, MouseEventArgs e)
        {
            if (this._Phong.TrangThai1.MaTTP == "3")
            {
                down = true;
                lastPosition = new Point();
                lastPosition.X = this.Location.X;
                lastPosition.Y = this.Location.Y;
                this.BringToFront();
            }
        }
        bool down = false;
        Point lastPosition;
       
    
        private void State_MouseMove(object sender, MouseEventArgs e)
        {
            if (down == true)
            {
                try
                {
                    UC_Phong phong = this;
                    Phong_Move(phong);
                }
                catch { }
            }
        }

        private void State_MouseUp(object sender, MouseEventArgs e) 
        {
            if (down)
            {
                down = false;

                Phong_Up(this);

                this.Location = lastPosition;
            }
        }
    }
}
